home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4411 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: news.tte.vtt.fi!newsmaster
  2. From: Ali Lattunen <Ali.Lattunen@vtt.fi>
  3. Newsgroups: comp.lang.c++
  4. Subject: Strange template behavior with Borland C++
  5. Date: 30 Jan 1996 07:35:21 GMT
  6. Organization: VTT Information Technology
  7. Message-ID: <4ekhnp$6pe@hemuli.tte.vtt.fi>
  8. NNTP-Posting-Host: tte2053.tte.vtt.fi
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  13.  
  14.  
  15. Hello all!
  16.  
  17. Has anyone else had problems with using templates with Borland C++ 4.5x
  18. compiler? I still haven't got the idea of how templates are treated by
  19. the compiler.
  20.  
  21. I have done everything according to the rules mentioned in the manuals:
  22. included both my template class declarations and member function
  23. implementations in the header files and compiled the whole project using
  24. the -Jg switch (smart templates).
  25.  
  26. However, the compiler is able to create only one instance of each member
  27. function. The link-time error occurs if member functions of several types
  28. of template classes are called.
  29.  
  30. If I have, for example, template class TemplClass<class T> with member
  31. function TemplClass<T>::Foo(), and have template instancies
  32. TemplClass<MyClass1> C1 and TemplClass<MyClass2> C2, calling foo as
  33. C1.Foo() works fine. But the C2.Foo() causes a linker error:
  34.  
  35. Undefined symbol TempClass<MyClass2>::Foo() in module...
  36.  
  37. What the heck? The problem is avoided if Foo is defined inline!?
  38. But why? What is the point in this?
  39.  
  40. ---------------------------------------------
  41.  Ali Lattunen
  42.  VTT Information Tecnology
  43.  Telecommunications
  44.  Otakaari 7 B, Espoo, P.O. Box 1202
  45.  FIN-02044 VTT
  46.  Finland
  47.  
  48.  phone: +358 0 456 6482
  49.  fax: +358 0 456 7013
  50.  email: Ali.Lattunen@vtt.fi
  51. ---------------------------------------------
  52.  
  53.